package com.bcpapp.project.model.dto.post;

import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 创建请求
 *
 * @TableName product
 */
@Data
public class PostBuyTicketRequest implements Serializable {

    @NotBlank(message = "公民身份证号码为空")
    private String gmsfhm;

    @NotBlank(message = "姓名为空")
    private String xm;

    private String lxdh;

    @NotBlank(message = "行为类型为空")
    private String xwlx;

    @NotBlank(message = "行为时间为空")
    private String xwsj;

    @NotBlank(message = "预约到达时间为空")
    private String yyddsj;

    @NotBlank(message = "景区名称为空")
    private String jqmc;

    @NotBlank(message = "景区地址为空")
    private String jqdz;

    @NotBlank(message = "景区坐标-经度为空")
    private String jd;

    @NotBlank(message = "景区坐标-维度为空")
    private String wd;

    @NotBlank(message = "运营公司名称为空")
    private String yygsmc;


    private static final long serialVersionUID = 1L;


    public String toStringt(){
        return  gmsfhm + "\t" +
                xm + "\t" +
                lxdh + "\t" +
                xwlx + "\t" +
                xwsj + "\t" +
                yyddsj + "\t" +
                jqmc + "\t" +
                jqdz + "\t" +
                jd + "\t" +
                wd + "\t" +
                yygsmc ;

    }
    public String toCsv() {
        return escapeCsvValue(gmsfhm) + "," +
                escapeCsvValue(xm) + "," +
                escapeCsvValue(lxdh) + "," +
                escapeCsvValue(xwlx) + "," +
                escapeCsvValue(xwsj) + "," +
                escapeCsvValue(yyddsj) + "," +
                escapeCsvValue(jqmc) + "," +
                escapeCsvValue(jqdz) + "," +
                escapeCsvValue(jd) + "," +
                escapeCsvValue(wd) + "," +
                escapeCsvValue(yygsmc);
    }

    /**
     * 对字段值进行 CSV 转义处理：如果包含逗号，则用双引号包裹
     */
    private String escapeCsvValue(String value) {
        if (value == null) {
            return "";
        }
        if (value.contains(",") || value.contains("\"") || value.contains("\n")) {
            return "\"" + value.replace("\"", "\"\"") + "\"";
        } else {
            return value;
        }
    }

}